import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.SortedSet;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import util.*;

public class SgxTopValues {

	private ArrayList<Candle> candles;

	public SgxTopValues(String filename) {
		candles = new ArrayList<Candle>();
		Util.readFile(filename, candles);
		
        Collections.sort(candles, new Comparator() {
            public int compare(Object o1, Object o2) {
            	Candle c1 = (Candle) o1;
            	Candle c2 = (Candle) o2;
            	
            	Float v1 = c1.getVolume() * c1.getPriceLow();
            	Float v2 = c2.getVolume() * c2.getPriceLow();
            	
                return -v1.compareTo(v2);
            }
        });

        Iterator<Candle> iter = candles.iterator();
        int count = 0;
		while (iter.hasNext()) {
			Candle candle = iter.next();
			count++;

			if (count < 30) {
				String paddedStockName = String.format("%1$-30s", candle.getStockName());
			      DecimalFormat formatter = new DecimalFormat("#.#"); 
				System.out.println(paddedStockName + "\t" + candle.getVolume() / 1000);
			}
		}
	}
	
	public static void main(String[] args) {
		new SgxTopValues(args[0]);
	}

}
